package com.xyzwps.orm.ebean;

import com.zaxxer.hikari.HikariDataSource;
import io.ebean.DB;
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.config.DatabaseConfig;

public class App {

    private final Database db;

    public App() {
        var ds = new HikariDataSource();
        ds.setJdbcUrl("jdbc:mysql://localhost:3306/orm");
        ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
        ds.setUsername("scott");
        ds.setPassword("tiger");

        var config = new DatabaseConfig();
        config.setDataSource(ds);

        this.db = DatabaseFactory.create(config);
    }

    public Database getDatabase() {
        return db;
    }
}
